package com.example.beautyuser.controller;

import com.example.beautyuser.dto.LoginRequest;
import com.example.beautyuser.entity.User;
import com.example.beautyuser.service.UserService;
import com.example.beautyuser.util.ResultVO;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {
    @Autowired
    private UserService userService;
    //登录
    @PostMapping("/login")
    public ResultVO login(@Valid @RequestBody LoginRequest request) {
        log.info("【用户服务】接收到登录请求，用户名: {}, 是否商家登录: {}",
                request.getUsername(), request.getIsMerchantLogin());
        return ResultVO.success(userService.login(request));
    }
}
